#include<iostream>
#include<vector>
using namespace std;


int main()
{
    int n;cin>>n;
    vector<int>s(n+1);
    int q=0;cin>>q;
    for(int i=1;i<=n;i++)cin>>s[i];
    vector<long long>dp(n+1);
    for(int i=0;i<=n;i++)
    dp[i]=dp[i-1]+s[i];
    while(q--)
    {
        int r=0,l=0;
        cin>>r>>l;
        cout<<dp[l]-dp[r-1]<<endl;
    }
    return 0;
}
